<?php
Database(getLoginPid());
class ChannelAction extends Action{
	public function index(){
		$rs=D('Channel')->get_list();
		$this->assign('rs',$rs);
		$this->display();
	}	
	public function addAct(){
		$_POST['time_insert']=time();
		$_POST['time_update']=time();
		$_POST['time_delete']=-1;
		$rs=D('Channel')->add_channel();
		if($rs)
			$this->success('添加成功');
		else
			$this->error('添加失败');
	}
	public function to_upt(){
		$rs=D('Channel')->get_one();
		$this->assign('rs',$rs);
		$this->display();
	}
	public function uptAct(){
		$_POST['time_update']=time();
		$rs=D('Channel')->upt_channel();
		if($rs)
			echo '{"state":0,"msg":"update success"}';
		else
			echo '{"state":-1,"msg":"update success"}';
	}
	public function delAct(){
		$rs=D('Channel')->del_channel();
		if($rs)
			echo '{"state":0,"msg":"delete success"}';
		else
			echo '{"state":-1,"msg":"delete success"}';
	}
}
?>